package com.yi.wood.sequence;

import com.yi.wood.utils.BinHexUtil;

/**
 * Created by moyi on 2019/1/30 18:07
 *
 * @author moyi
 */
public class SnowflakeTest {
    public static void main(String[] args) {
        // 构造方法设置机器码：第2个机房的第5台机器
        Snowflake snowflake = new Snowflake(1,1);
        int size = 20;
        for (int i = 0; i < size; i++) {
            Long id = snowflake.nextId();
            System.out.println(String.format("%s => id: %d, hex: %s, bin: %s", snowflake.formatId(id), id,
                    BinHexUtil.hex(id), BinHexUtil.bin(id)));
        }
    }
}
